package com.yijiaganxi.services.web;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yijiaganxi.services.service.banner.YjgxBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.yijiaganxi.common.entity.banner.YjgxBanner;

@RestController
public class TestController {

    @Autowired
    private YjgxBannerService bannerService;

    @GetMapping("queryTestGet1")
    public Object queryTestGet1(){
        return bannerService.selectList(new EntityWrapper<>());
    }

    @GetMapping("queryTestGet2")
    public YjgxBanner queryTestGet2(){
        return bannerService.selectList(new EntityWrapper<>()).get(0);
    }

    @GetMapping("queryTestGet3")
    public Object queryTestGet3(String id){
        return bannerService.selectList(new EntityWrapper<YjgxBanner>().eq("id",id));
    }

    @GetMapping("queryTestGet4")
    public YjgxBanner queryTestGet4(String id){
        return bannerService.selectList(new EntityWrapper<YjgxBanner>().eq("id",id)).get(0);
    }

    @PostMapping("queryTestGet5")
    public YjgxBanner queryTestGet5(@RequestBody YjgxBanner banner){
        int a=1/0;
        return bannerService.selectList(new EntityWrapper<YjgxBanner>().eq("id",banner.getId())).get(0);
    }







    @PostMapping("queryTestPost1")
    public Object queryTestPost1(){
        return bannerService.selectList(new EntityWrapper<>());
    }

    @PostMapping("queryTestPost2")
    public YjgxBanner queryTestPost2(){
        return bannerService.selectList(new EntityWrapper<>()).get(0);
    }

    @PostMapping("queryTestPost3")
    public Object queryTestPost3(String id){
        return bannerService.selectList(new EntityWrapper<YjgxBanner>().eq("id",id));
    }

    @PostMapping("queryTestPost4")
    public YjgxBanner queryTestPost4(String id){
        return bannerService.selectList(new EntityWrapper<YjgxBanner>().eq("id",id)).get(0);
    }
    @PostMapping("queryTestPost5")
    public YjgxBanner queryTestPost5(@RequestBody YjgxBanner banner) throws InterruptedException {
        Thread.sleep(5000);
        return bannerService.selectList(new EntityWrapper<YjgxBanner>().eq("id",banner.getId())).get(0);
    }
}
